import { createRouter, createWebHistory } from 'vue-router'
import layout from '@/layout/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      name: 'login',
      hidden: true,
      component: () => import('@/views/login/index.vue')
    },
    {
      path: '/',
      name: 'layout',
      component: layout,
      redirect: '/dashboard',
      children: [
        {
          path: '/dashboard',
          name: 'dashboard',
          component: () => import('@/views/dashboard/index.vue'),
          meta: {
            title: '首页'
          }
        }
      ]
    },
    {
      path: '/clue',
      name: 'clue',
      component: layout,
      children: [
        {
          path: '/clue/index',
          name: 'clue-index',
          component: () => import('@/views/clue/index.vue'),
          meta: {
            title: '线索管理'
          }
        },
        {
          path: '/clue/follow-up/:clueId?',
          name: 'follow-up',
          component: () => import('@/views/clue/components/follow-up.vue'),
          meta: {
            title: '线索跟进'
          },
          hidden: false
        },
      ]
    },

    {
      path: '/lead-management',
      meta: { title: '商机管理' },
      children: [
        {
          path: '/lead-management/lead',
          name: 'lead',
          component: layout,
          meta: { title: '商机管理' },
          children: [
            {
              path: '/lead-management/lead/opportunity',
              name: 'lead',
              component: () => import('@/views/LeadManagement/BusinessOpportunity.vue'),
              meta: { title: '商机' }
            },
            {
              path: '/lead-management/lead/OpenSeaPool',
              name: 'OpenSeaPool',
              component: () => import('@/views/LeadManagement/OpenSeaPool.vue'),
              meta: { title: '公海池' }
            }
          ]
        }
      ]
    },

    // {
    //   path: '/business',
    //   name: 'business',
    //   component: layout,
    //   children: [
    //     {
    //       path: '/business/index',
    //       name: 'business-index',
    //       component: () => import('@/views/business/index.vue'),
    //       meta: {
    //         title: '商机管理'
    //       }
    //     }
    //   ]
    // },
    {
      path: '/contract',
      name: 'contract',
      component: layout,
      children: [
        {
          path: '/contract/index',
          name: 'contract-index',
          component: () => import('@/views/ContractManagement/index.vue'),
          meta: {
            title: '合同管理'
          }
        }
      ]
    },
    {
      path: '/details',
      name: 'details',
      component: () => import('@/views/ContractManagement/details/index.vue'),
      meta: {
        title: '合同详情'
      },
      hidden: true
    },
    {
      path: '/reassignment',
      name: 'reassignment',
      component: () => import('@/views/reassignment/index.vue'),
      meta: {
        title: '转派管理'
      }
    },
    {
      path: '/basic-data',
      component: layout,
      meta: { title: '基础数据维护' },
      redirect: '/basic-data/activities',
      children: [
        {
          path: '/basic-data/activities',
          name: 'activities',
          component: () => import('@/views/basicDataMaintenance/activities.vue'),
          meta: { title: '活动管理' }
        }
      ]
    },
    {
      path: '/course',
      name: 'course',
      component: layout,
      children: [
        {
          path: '/course/index',
          name: 'course-index',
          component: () => import('@/views/course/index.vue'),
          meta: {
            title: '课程管理'
          }
        }
      ]
    },
    // {
    //   path: '/events',
    //   name: 'events',
    //   component: layout,
    //   children: [
    //     {
    //       path: '/events/index',
    //       name: 'events-index',
    //       component: () => import('@/views/basicDataMaintenance/activities/index.vue'),
    //       meta: {
    //         title: '活动管理'
    //       }
    //     }
    //   ]
    // },

    // {
    //   path: '/older',
    //   name: 'older',
    //   component: layout,
    //   children: [
    //     {
    //       path: '/older/index',
    //       name: 'older-index',
    //       component: () => import('@/views/older/index.vue'),
    //       meta: {
    //         title: '工单管理'
    //       }
    //     }
    //   ]
    // },
    {
      path: '/statistics',
      name: 'statistics',
      component: layout,
      children: [
        {
          path: '/statistics/index',
          name: 'statistics-index',
          component: () => import('@/views/statisticalAnalysis/index.vue'),
          meta: {
            title: '统计分析'
          }
        }
      ]
    },
    {
      path: '/system',
      name: 'system',
      meta: { title: '系统管理' },
      component: layout,
      children: [
        {
          path: '/system/limits',
          name: 'limits',
          redirect: '/system/limits/user-manage',
          meta: {
            title: '权限管理'
          },
          children: [
            {
              path: '/system/limits/user-manage',
              name: 'user-manage',
              component: () => import('@/views/system/permission/user/index.vue'),
              meta: {
                title: '用户管理'
              }
            },
            // {
            //   path: '/system/limits/role-manage',
            //   name: 'role-manage',
            //   component: () => import('@/views/system/limits/role-manage.vue'),
            //   meta: {
            //     title: '角色管理'
            //   }
            // },
            {
              path: '/system/limits/menu-manage',
              name: 'menu-manage',
              component: () => import('@/views/system/permission/menu/index.vue'),
              meta: {
                title: '菜单管理'
              }
            },
            {
              path: '/system/permission/section',
              name: 'section-manage',
              component: () => import('@/views/system/permission/section/index.vue'),
              meta: {
                title: '部门管理'
              }
            },
            {
              path: '/system/limits/post-manage',
              name: 'post-manage',
              component: () => import('@/views/system/permission/post/index.vue'),
              meta: {
                title: '岗位管理'
              }
            }
          ]
        },
        {
          path: '/system/dictionaries-manage',
          name: 'dictionaries-manage',
          component: () => import('@/views/system/permission/dictionary/index.vue'),
          meta: {
            title: '字典管理'
          }
        },
        // {
        //   path: '/system/clue-config',
        //   name: 'clue-config',
        //   component: () => import('@/views/system/clue-config.vue'),
        //   meta: {
        //     title: '线索配置'
        //   }
        // },
        {
          path: '/system/system-logs',
          name: 'system-logs',
          component: () => import('@/views/system/systemLog/index.vue'),
          meta: {
            title: '系统日志'
          }
        }
        // {
        //   path: '/system/log-out',
        //   name: 'log-out',
        //   component: () => import('@/views/system/log-out.vue'),
        //   meta: {
        //     title: '退出系统'
        //   }
        // }
      ]
    }
  ]
})

export default router
